<template>
  <div id="review">
    <div class="el_content">
      <el-row class="edit-title">
        <el-col :span="20">
          <span>预约时间：</span>2018.11.25(周日)11:00-12:00
        </el-col>
        <el-col :span="2" :push="2" class="text-right">
          <el-button
            class="back"
            type="info"
            size="mini"
            plain
            icon="el-icon-arrow-left"
            @click="goBack"
          >返回</el-button>
        </el-col>
      </el-row>
      <el-form :model="info" :rules="rules" ref="info" label-width="90px" class="el_t_20">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="姓名：" prop="name">
              <el-autocomplete
                class="el_long"
                v-model="info.name"
                :fetch-suggestions="querySearch"
                suffix-icon="el-icon-search"
                placeholder="请输入或选择患者姓名"
                @select="handleSelect"
              ></el-autocomplete>
            </el-form-item>
            <el-form-item label="电话：" prop="phone">
              <el-input v-model="info.phone" placeholder="请输入患者联系电话，多个请用逗号隔开"></el-input>
            </el-form-item>
            <el-form-item label="出生日期：">
              <el-date-picker class="el_long" v-model="info.name" type="date" placeholder="选择日期"></el-date-picker>
            </el-form-item>
            <el-form-item label="文化：">
              <el-select v-model="info.name" placeholder="请选择患者文化程度" class="el_long">
                <el-option label="请选择患者文化程度" :value="1"></el-option>
                <el-option label="为受教育" :value="1"></el-option>
                <el-option label="小学" :value="2"></el-option>
                <el-option label="初中" :value="3"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="性别：" prop="sex">
              <el-radio-group v-model="info.sex">
                <el-radio :label="'男'">男</el-radio>
                <el-radio :label="'女'">女</el-radio>
                <el-radio :label="'不详'">不详</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="身份证号：">
              <el-input v-model="info.name" placeholder="输入患者身份证号"></el-input>
            </el-form-item>
            <el-form-item label="婚姻：">
              <el-select v-model="info.name" placeholder="选择婚姻状况" class="el_long">
                <el-option label="选择婚姻状况" :value="1"></el-option>
                <el-option label="未婚" :value="1"></el-option>
                <el-option label="已婚" :value="2"></el-option>
                <el-option label="丧偶" :value="3"></el-option>
                <el-option label="离异" :value="4"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="职业：">
              <el-select v-model="info.name" placeholder="请选择患者职业" class="el_long">
                <el-option label="请选择患者职业" :value="1"></el-option>
                <el-option label="未婚" :value="1"></el-option>
                <el-option label="已婚" :value="2"></el-option>
                <el-option label="丧偶" :value="3"></el-option>
                <el-option label="离异" :value="4"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="地址：">
          <el-row>
            <el-col :span="5">
              <el-select v-model="info.name" placeholder="选择省" class="el_90">
                <el-option label="选择省" :value="1"></el-option>
              </el-select>
            </el-col>
            <el-col :span="5">
              <el-select v-model="info.name" placeholder="选择市" class="el_90">
                <el-option label="选择省" :value="1"></el-option>
              </el-select>
            </el-col>
            <el-col :span="5">
              <el-select v-model="info.name" placeholder="选择区" class="el_90">
                <el-option label="选择省" :value="1"></el-option>
              </el-select>
            </el-col>
            <el-col :span="9">
              <el-input type="text" placeholder="请输入详细地址信息"></el-input>
            </el-col>
          </el-row>
        </el-form-item>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="推荐人：">
              <el-select v-model="info.name" placeholder="请选择患者来源" class="el_long">
                <el-option label="请选择患者来源" :value="1"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="备注：">
          <el-input type="textarea" :rows="4" placeholder="输入备注信息"></el-input>
        </el-form-item>
      </el-form>
      <el-row class="footer-fixed">
        <el-col :span="24" class="text-right">
          <el-button type="primary" plain>取消预约</el-button>
          <el-button type="primary" @click="submitInfo('info')">确认预约</el-button>
        </el-col>
      </el-row>
    </div>
  </div>
</template>
<script>
export default {
  name: "review",
  data() {
    return {
      info: {
        name: "",
        phone: "",
        sex: ""
      },
      rules: {
        name: [{ required: true, message: "姓名不能为空", trigger: "blur" }],
        sex: [{ required: true, message: "性别不能为空", trigger: "change" }],
        phone: [{ required: true, message: "电话不能为空", trigger: "blur" }]
      },
      restaurants: [
        { value: "三全鲜食（北新泾店）", address: "长宁区新渔路144号" },
        {
          value: "Hot honey 首尔炸鸡（仙霞路）",
          address: "上海市长宁区淞虹路661号"
        },
        {
          value: "新旺角茶餐厅",
          address: "上海市普陀区真北路988号创邑金沙谷6号楼113"
        },
        { value: "泷千家(天山西路店)", address: "天山西路438号" }
      ]
    };
  },
  methods: {
    submitInfo(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          alert("验证通过！");
        } else {
          return false;
        }
      });
    },
    goBack() {
      this.$router.go(-1);
    },
    querySearch(queryString, cb) {
      var restaurants = this.restaurants;
      var results = queryString
        ? restaurants.filter(this.createFilter(queryString))
        : restaurants;
      // 调用 callback 返回建议列表的数据
      cb(results);
    },
    handleSelect(item) {
      console.log(item);
    }
  }
};
</script>
<style scoped>
.el_content {
  width: 100%;
  height: calc(100vh - 108px);
  background: #ffffff;
  padding: 20px;
}
.edit-title {
  padding-bottom: 10px;
  border-bottom: 1px solid #e4e4e4;
  color: #006835;
  font-weight: 700;
}
.edit-title span {
  color: #999;
}
</style>